/**@FILE:OpenSearchUtil.java
 * @AUTHOR:qingsheng.zheng
 * @DATE:2015-3-31 上午11:25:15*/
package com.fz.tool.aliyun.opensearch;

import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;

import com.opensearch.javasdk.CloudsearchClient;
import com.opensearch.javasdk.object.KeyTypeEnum;

/*******************************************
 * @COMPANY:alibaba
 * @CLASS:OpenSearchUtil
 * @DESCRIPTION:	
 * @AUTHOR:qingsheng.zheng
 * @VERSION:v1.0
 * @DATE:2015-3-31 上午11:25:15
 *******************************************/
public class OpenSearchUtil {
    private static final String  ACCESSKEY = "xxx";
    private static final String  SECRET  = "xxx";
    private static final String  URL = "http://opensearch.aliyuncs.com";
    private static CloudsearchClient client;
    private static Object lock = new Object();
    public static CloudsearchClient getInstance() throws MalformedURLException {
        if (client == null) {
            synchronized (lock) {
                if (client == null) {
                   Map<String, Object> opts = new HashMap<String, Object>();
                     opts.put("host", URL);
                     client = new CloudsearchClient(ACCESSKEY, SECRET , opts,KeyTypeEnum.ALIYUN);
                }
            }
        }
        return client;
    }
}
